﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SeaBattle.Domain.Abstract;
using SeaBattle.Domain.Entities;

namespace SeaBattle.Domain.Concrete
{
    public class FakeShipRepository : IShipRepository
    {
        private static List<Ship> ships = new List<Ship>();

        /// <summary>
        /// Gets the ship.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public Ship GetShip(int id)
        {
            return ships.FirstOrDefault(x => x.Id == id);
        }

        /// <summary>
        /// Creates the ship.
        /// </summary>
        /// <param name="partsCount">The parts count.</param>
        /// <returns></returns>
        public Ship CreateShip(byte partsCount)
        {
            var ship = new Ship(partsCount) { Id = ships.Count + 1 };
            ships.Add(ship);
            return ship;
        }

        /// <summary>
        /// Saves the ship.
        /// </summary>
        /// <param name="ship">The ship.</param>
        /// <returns></returns>
        public Ship SaveShip(Ship ship)
        {
            return ship;
        }
    }
}
